#! /bin/sh

prefix=/usr/local/racoon2
exec_prefix=${prefix}

PATH=${exec_prefix}/sbin:${exec_prefix}/bin:$PATH
DAEMON=${exec_prefix}/sbin/spmd
DAEMON_OPT="-F -D 2"
NAME="spmd"

test -x $DAEMON || exit 0


set -e

case "$1" in
  start)
	mkdir -p -m 700 /var/run/racoon2
	# XXX check owner and mode
	echo -n "Starting $NAME"
	$DAEMON $DAEMON_OPT
	sleep 1				# Wait until spmif is bound.
	echo "."
	;;
  stop)
	echo -n "Stopping $NAME"
	$DAEMON -k
	echo "."
	;;
  restart|force-reload)
  	$0 stop
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
